package com.jiuyou.clientController.technicianopus;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jiuyou.clientController.base.ClientBaseController;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.technician.domain.StoreTechnician;
import com.ruoyi.technician.service.IStoreTechnicianService;
import com.ruoyi.technicianOpus.domain.StoreTechnicianOpus;
import com.ruoyi.technicianOpus.service.IStoreTechnicianOpusService;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *技师相关
 *
 * @author jiuyou
 */
@Api(tags = {"C端技师作品相关"})
@RestController
@RequestMapping("/client/technicianOpus")
public class TechnicianOpusClientController extends ClientBaseController
{
    private static final Logger log = LoggerFactory.getLogger(TechnicianOpusClientController.class);
    @Autowired
    private IStoreTechnicianOpusService storeTechnicianOpusService;

    /**
     * 查询技师信息列表
     */
    @ApiOperation(value = "查询技师作品列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前第几页",dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize",value = "每页几条数据",dataType = "Integer"),
            @ApiImplicitParam(name = "storeId",value = "门店id",required = true, dataType = "Long"),
            @ApiImplicitParam(name = "techId",value = "技师id", dataType = "Long"),
            @ApiImplicitParam(name = "opusType",value = "作品类型，图片img，视频video",dataType = "String"),
    })
    @PostMapping("/list")
    public AjaxResult list(Long storeId,Long techId,String opusType,Integer pageNum,Integer pageSize)
    {
        StoreTechnicianOpus storeTechnicianOpusparam=new StoreTechnicianOpus();
        storeTechnicianOpusparam.setStoreId(storeId);
        storeTechnicianOpusparam.setTechId(techId);
        storeTechnicianOpusparam.setOpusType(opusType);
        startPage();
        List<StoreTechnicianOpus> list = storeTechnicianOpusService.selectStoreTechnicianOpusList(storeTechnicianOpusparam);
        //List<JSONObject> resultList=new ArrayList<JSONObject>();
        TableDataInfo tableDataInfo =getDataTable(list);
        list= (List<StoreTechnicianOpus>) tableDataInfo.getRows();

        tableDataInfo.setRows(list);
        return AjaxResult.success(tableDataInfo);
    }


    /**
     * 获取技师信息详细信息
     */
    @ApiOperation(value = "获取作品详情")
    @ApiImplicitParam(name = "id",value = "作品id",dataType = "Long")
    @PostMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        StoreTechnicianOpus storeTechnicianOpus= storeTechnicianOpusService.selectStoreTechnicianOpusById(id);

        return AjaxResult.success(storeTechnicianOpus);
    }



}
